package org.anarcoding.twitterbot.main;

import java.util.List;

import org.anarcoding.twitterbot.model.Tweet;
import org.anarcoding.twitterbot.providers.AnarcoTwitterServicesProvider;
import org.anarcoding.twitterbot.services.IAnarcoTwitterServices;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;

import com.anarcoding.util.SWTUtil;

public class Main {
	public static void main( String [] args ) {

		Shell shl = new Shell();

		try {
			AnarcoTwitterServicesProvider.inicalizarServicios();
			
			List< IAnarcoTwitterServices > twitters = AnarcoTwitterServicesProvider.getIAnarcoTwitterServicesFromDB( true );
			
			for( IAnarcoTwitterServices twitter : twitters ) {
				
				Tweet tweet = new Tweet();
				tweet.setTweetMsg( "Twitteando desde @anarcoding :D:D @d3monix @AeroVM" );
				
				System.out.println( "Twitter: " + twitter );
				System.out.println( "Twiteando: " + tweet.getTweetMsg() );
				
				twitter.doTweet( tweet );
				
				System.out.println( "OK" );
			}
			
			
		} catch( Exception e ) {
			SWTUtil.openDialog( shl, "Error", "Error al inicializar AnarcoTwitterBot :(\r\n" + e.getMessage(), SWT.ICON_ERROR );
		}
	}
}